package com.autumn.cloud.demo.consumer.configure;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.client.RestTemplate;

/**
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-12-10 18:51
 **/
@Configuration
public class ClientAutoConfigure {

    public static final String BEAN_REST_BALANCED_TEMPLATE = "restBalancedTemplate";

    public static final String BEAN_REST_TEMPLATE = "restTemplate";

    /**
     * RestTemplate 负载均衡
     *
     * @return
     */
    @Bean(BEAN_REST_BALANCED_TEMPLATE)
    // 负载均衡(只能是注册中心的服务)
    @LoadBalanced
    @Primary
    public RestTemplate restBalancedTemplate() {
        return new RestTemplate();
    }

    /**
     * RestTemplate 通用，普通调用，其他第三方等
     *
     * @return
     */
    @Bean(BEAN_REST_TEMPLATE)
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }


}
